import xlrd

wd = xlrd.open_workbook('a.xls')

print(wd.nsheets)

sheet_names = wd.sheet_names()

print(wd.sheet_names())

for i in sheet_names:
    print(i)

sh1 = wd.sheet_by_index(0)
sh2 = wd.sheet_by_name('firstsheet')

print(sh1)
print(sh2)

print(f'sheet 里面一共又{sh1.nrows}行{sh1.ncols}列数据')

print(f'sheet 里面一共又{sh2.nrows}行{sh2.ncols}列数据')

print(f'{sh1.cell_value(0, 0)}')
print(f'{sh1.cell(0, 0).value}')
print(f'{sh1.row(0)[0].value}')

# 获取整行或者整列
print(sh1.row_values(0))
print(sh1.col_values(0))

# 遍历
for r in range(sh1.nrows):
    for c in range(sh1.ncols):
        print(f'第{r}行，第{c}列,的值是 {sh1.cell_value(r, c)}')


